//机票淡季旺季问题
//夏梓豪
//2023/04/01


package Code1_2;

import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {
        //输入信息，机票价格，机票类型，头等舱还是经济舱
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入机票的原价：");
        int ticket = sc.nextInt();
        System.out.println("请输入机票的购买月份：");
        int month = sc.nextInt();
        if (month < 1 || month > 12){
            System.out.println("您输入了非法数据，程序结束！！！");
            System.exit(1);
        }
        System.out.println("请输入您购买的是经济舱还是头等舱：");
        String seat = sc.next();

        if(month >= 5 && month <=10){
            extracted(ticket, seat);
        } else if ((month >= 11 && month <= 12) || month >=1 && month <=4) {
            switch (seat) {
                case "头等舱":
                    System.out.println("您需要支付" + ticket * 0.7 + "元");
                    break;
                case "经济舱":
                    System.out.println("您需要支付" + ticket * 0.65 + "元");
                    break;
            }
        }
    }


//注意，在idea中，ctrl + alt + M 可以快速提取方法并使用，但将private改为public

    public static void extracted(int ticket, String seat) {
        switch (seat){
            case "头等舱":
                System.out.println("您需要支付"+ ticket *0.9+"元");
                break;
            case "经济舱":
                System.out.println("您需要支付"+ ticket *0.85+"元");
                break;
        }
    }
}
